/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package compiler;

/**
 *
 * @author Paul.Kogel
 */
public class Relation
{

    private Table StartT;
    private Table EndT;
    private Column StartC;
    private Column EndC;
    

    public Column getEndC() {
        return EndC;
    }

    public void setEndC(Column EndC) {
        this.EndC = EndC;
    }

    public Table getEndT() {
        return EndT;
    }

    public void setEndT(Table EndT) {
        this.EndT = EndT;
    }

    public Column getStartC() {
        return StartC;
    }

    public void setStartC(Column StartC) {
        this.StartC = StartC;
    }

    public Table getStartT() {
        return StartT;
    }

    public void setStartT(Table StartT) {
        this.StartT = StartT;
    }

    public static enum Operations {RESTRICT,CASCADE,NO_ACTION,SET_NULL};

    private Operations UpdateOperation;

    public Operations getUpdateOperation() {
        return UpdateOperation;
    }

    public void setUpdateOperation(Operations UpdateOperation) {
        this.UpdateOperation = UpdateOperation;
    }

    private Operations DeleteOperation;

    public Operations getDeleteOperation() {
        return DeleteOperation;
    }

    public void setDeleteOperation(Operations DeleteOperation) {
        this.DeleteOperation = DeleteOperation;
    }

    public static Relation.Operations stringToOp(String s)
    {
        s = s.trim().toLowerCase();
        
        if (s.equals("restrict")) {
            return Relation.Operations.RESTRICT;
        }
        if (s.equals("cascade")) {
            return Relation.Operations.CASCADE;
        }
        if (s.equals("no action")) {
            return Relation.Operations.NO_ACTION;
        }
        if (s.equals("set null")) {
            return Relation.Operations.SET_NULL;
        }
        return null;
    }



}
